import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

export const Layout = () => import("@/layout/index.vue");

// 静态路由
export const constantRoutes: RouteRecordRaw[] = [
	{
		path: "/",
		component: () => import("@/views/dashboard/index.vue"),
		redirect: "/dashboard",
		meta: { title: "首页", icon: "home", affix: true },
		children: [
		{
			path: "dashboard",
			component: () => import("@/views/dashboard/index.vue"),
			name: "Dashboard",
			meta: { title: "首页", icon: "home", affix: true },
		},
		
		],
	},
	{
		path: "/redirect",
		component: Layout,
		meta: { hidden: true },
		children: [
		{
			path: "/redirect/:path(.*)",
			component: () => import("@/views/redirect/index.vue"),
		},
		],
	},
	{
		path: "/test",
		component: () => import("@/views/dashboard/test.vue"),
		meta: { hidden: true },
	},
	{
		path: "/login",
		component: () => import("@/views/login/index.vue"),
		meta: { hidden: true },
	},
	{
		path: "/register",
		component: () => import("@/views/login/register.vue"),
		meta: { hidden: true },
	},
	{
		path: "/information",
		component: () => import("@/views/login/information.vue"),
		meta: { hidden: true },
	},
	
	{
		path: "/integral",
		component: () => import("@/views/integral/index.vue"),
		meta: { hidden: true },
	},
	
	
	{
		path: "/list",
		component: () => import("@/views/dashboard/list.vue"),
		meta: { hidden: true },
	},
	{
		path: "/member",
		component: () => import("@/views/shop/userIndex.vue"),
		meta: { hidden: true },
	},
	{
		path: "/shop",
		component: () => import("@/views/shop/shop.vue"),
		meta: { hidden: true },
	},
	{
		path: "/view",
		component: () => import("@/views/shop/view.vue"),
		meta: { hidden: true },
	},
	{
		path: "/perfect",
		component: () => import("@/views/shop/userEdit.vue"),
		meta: { hidden: true },
	},
	
	{
		path: "/ranklist",
		component: () => import("@/views/shop/rankingList.vue"),
		meta: { hidden: true },
	},
	{
		path: "/word",
		component: () => import("@/views/plugins/word.vue"),
		meta: { hidden: true },
	},
	{
		path: "/401",
		component: () => import("@/views/error-page/401.vue"),
		meta: { hidden: true },
	},
	{
		path: "/404",
		component: () => import("@/views/error-page/404.vue"),
		meta: { hidden: true },
	},
];

/**
 * 创建路由
 */
const router = createRouter({
  history: createWebHashHistory('/chat'),
  routes: constantRoutes as RouteRecordRaw[],
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

/**
 * 重置路由
 */
export function resetRouter() {
  router.replace({ path: "/login" });
}

export default router;
